import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Home-pc
 * Date: 2023-08-22
 * Time: 22:07
 */
public class MinStack {
    private Stack<Integer> stack;
    private Stack<Integer> minStack;
    public MinStack() {
        stack=new Stack<>();
        minStack=new Stack<>();

    }

    public void push(int val) {
        st
        //首次往栈中放元素，最小栈中也要放
        if(minStack.empty()){
            minStack.push(val);
        }else if(minStack.peek()>=val){        //新加入进来的元素小于peek，那么它就需要入最小栈
            //相等也要入栈，因为在出栈的时候，要拿走和出栈元素相等的最小栈中的元素
            minStack.push(val);
        }
    }

    public void pop() {
        int val=stack.pop();
        if(val==minStack.peek()){
            minStack.pop();
        }

    }

    public int top() {
        return stack.peek();

    }

    public int getMin() {
        return minStack.peek();

    }

    public static void main(String[] args) {
        MinStack minStack=new MinStack();
        minStack.push(-2);
        minStack.push(0);
        minStack.push(-3);
        System.out.println(minStack.getMin());
        minStack.pop();
        minStack.top();
        minStack.getMin();
    }
}

